package m1.server.connectionmanager;

import m1.server.securitymanager.SecurityAuthorization;
import m2.component.Component;
import m2.component.iface.ComponentInterfaceServiceRequis;
import m2.connector.Connector;
import m2.connector.iface.RoleFrom;

public class SecurityCheck extends ComponentInterfaceServiceRequis {

	public SecurityCheck(String name) {
		super(name);
	}
	
	public boolean serviceCheckUser() {
		System.out.println("Service requis : " + getName() + " du composant " + this.getComponentInterface().getComponent().getName());
		Connector c = getAttach().getRoleTo().getConnecteur();
		SecurityAuthorization sa = (SecurityAuthorization) ((RoleFrom) c.getRole("Grantor")).getAttach().getFourni();
		String id = getComponentInterface().getComponent().getProperties().get("id").getName();
		String pass = getComponentInterface().getComponent().getProperties().get("pass").getName();
		return sa.serviceAuthorization(id,pass);
		
	}

}
